<?php
if (!defined('BASEPATH')) exit('No direct script access allowed');

class MY_controller extends CI_Controller {
	private $data;
	private $view;
	
	public function __construct() {
		$this->data = array();
		$this->view = "home";
        parent::__construct();
    }
	
	public function setData($newData) {
		
		foreach($newData as $chave => $valor){
			if(is_array($valor))
				$this->data[$chave] = array();
			
			$this->data[$chave] = $valor;
		}
	}
	
	private function setView($newView) {
		$this->view = $newView;
	}
	
	private function header($newTitle = "Spend Control | Gestor Financeiro Pessoal") {
		$this->setData(
			$newData = array(
				"title" => $newTitle,
				
				"css" => array(
					"main"
				),
				
				"js" => array(
					"plugin/min/jquery-1.7.1.min",
					"plugin/min/jquery-ui-1.8.17.custom.min",
					"main"
				)
			)
		);
		
		$this->load->view("commun/header", $this->data);
	}
	
	private function menu() {
		$this->load->view("commun/menu");
	}
	
	private function footer() {
		$this->load->view("commun/footer");
	}
	
	public function usable($view, $title) {
		if(isset($view))
			$this->setView($view, $title);
		
		$this->header($title);
		$this->menu();
		$this->load->view($view);
		$this->footer();
	}
}
?>